const seq = require('../db/seq');
const Exercises = require('../model/exercises');

const exercises = Exercises(seq);

class ExercisesController {
    async show(ctx, next) {
        try {
            const res = await exercises.findAll({ order: seq.random(), limit: 5 });
            ctx.body = {
                code: 0,
                message: '获取题目信息成功',
                result: JSON.stringify(res)
            }
        } catch (err) {
            console.log(err);
            return ctx.body = {
                error: '获取题目信息失败'
            }
        }
    }
}

module.exports = new ExercisesController();